﻿using Lcygcc.Infrastructure.Core;
using Lcygcc.Infrastructure.Logs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lcygcc.Domain.TaskService
{
    public class BaseTaskService : IBaseTaskService
    {
        public RequestArgs RequestArgs;

        public string CloudSend()
        {
            try
            {
                var adapter = EngineContext.Current.Resolve<IBaseChannel>(this.RequestArgs.ServiceID);
                var method = adapter.GetType().GetMethod(this.RequestArgs.AdapterMethod);
                var request = method.Invoke(adapter, new object[] { this }) as RequestArgs;
            }
            catch (Exception ex)
            {
                Logger.Error("-----BaseTaskService.CloudSend-----", ex);
            }
            return string.Empty;
        }

        public string TimerSend()
        {
            try
            {
                var adapter = EngineContext.Current.Resolve<ITaskWork>(this.RequestArgs.ServiceID);
                var method = adapter.GetType().GetMethod(this.RequestArgs.AdapterMethod);
                var request = method.Invoke(adapter,new object[] { this.RequestArgs }) as RequestArgs;
            }
            catch (Exception ex)
            {
                Logger.Error("-----BaseTaskService.TimerSend-----", ex);
            }
            return string.Empty;
        }
    }
}
